package com.lzy.cloud.order.controller;

import com.lzy.cloud.order.dtos.pay.OrderPayParamsDto;
import com.lzy.cloud.order.facade.OrderPayFacade;
import com.lzy.framework.core.ensure.Ensure;
import com.lzy.framework.core.output.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 订单-支付相关
 * @Author:   gyl
 * @Date:     2018/7/10 10:59
 */
@RestController
@RequestMapping("/order/pay")
public class OrderPayController {

    @Autowired
    private OrderPayFacade orderPayFacade;

    /**
     * 方法说明：根据订单号查询订单支付信息
     * @param    orderId
     * @return
     * @date        2018/7/10 11:04
     */
    @GetMapping("/find")
    public Result findToPay(String orderId) {
        orderPayFacade.findToPay(orderId);
        return new Result();
    }

    /**
     * 方法说明：根据订单号更新相关信息
     * @param orderPayParamsDto
     * @return
     * @date        2018/7/10 11:13
     */
    @PostMapping("/update/pay")
    public Result updateFromPay(@RequestBody OrderPayParamsDto orderPayParamsDto) {
        Ensure.that(orderPayParamsDto).isNotNull("00000002");
        Boolean ok = orderPayFacade.updateFromPay(orderPayParamsDto);
        Ensure.that(ok).isTrue("");
        return new Result();
    }

    /**
     * 方法说明：退款更新相关信息
     * @param orderPayParamsDto
     * @return      
     * @date        2018/7/10 11:26
     */
    @PostMapping("/update/refund")
    public Result updateFromRefund(@RequestBody OrderPayParamsDto orderPayParamsDto) {
        Ensure.that(orderPayParamsDto).isNotNull("00000002");
        Boolean ok = orderPayFacade.updateFromRefund(orderPayParamsDto);
        Ensure.that(ok).isTrue("");
        return new Result();
    }
}
